<?php

namespace App\Http\Requests\Api;

class PrizeRequest extends FormRequest
{

    public function rules()
    {
        switch($this->method()) {

            case 'POST':
                return [
                    'status' => 'required|integer',
                    'quantity' => 'required|integer',
                    'remain_quantity' => 'required|integer',
                    'user_redeeming_quantity' => 'required|integer',
                    'accumulate_point' => 'required|integer',
                    'shelves_begin' => 'required|date',
                    'shelves_end' => 'required|date',
                    'redeeming_begin' => 'required|date',
                    'redeeming_end' => 'required|date',
                    'redeemed_begin' => 'required|date',
                    'redeemed_end' => 'required|date',
                    'product_id' => 'required|exists:products,id',
                ];
                break;

            case 'PATCH':
                return [
                    'status' => 'integer',
                    'quantity' => 'integer',
                    'remain_quantity' => 'integer',
                    'user_redeeming_quantity' => 'integer',
                    'accumulate_point' => 'integer',
                    'shelves_begin' => 'date',
                    'shelves_end' => 'date',
                    'redeeming_begin' => 'date',
                    'redeeming_end' => 'date',
                    'redeemed_begin' => 'date',
                    'redeemed_end' => 'date',
                    'product_id' => 'exists:products,id',
                ];
                break;
        }
    }

    public function attributes()
    {
        return [
            'status' => '上架状态',
            'quantity' => '数量',
            'remain_quantity' => '剩余数量',
            'user_redeeming_quantity' => '允许兑换数量',
            'accumulate_point' => '积分',
            'shelves_begin' => '上架开始时间',
            'shelves_end' => '上架结束时间',
            'redeeming_begin' => '兑奖开始时间',
            'redeeming_end' => '兑奖结束时间',
            'redeemed_begin' => '领奖开始时间',
            'redeemed_end' => '领奖结束时间',
            'product_id' => '产品id',
        ];
    }
}
